package cn.kgc.airquality.airquality.service.impl.impl;

import cn.kgc.airquality.airquality.mapper.QualityMapper;
import cn.kgc.airquality.airquality.pojo.Quality;
import cn.kgc.airquality.airquality.pojo.QualityExample;
import cn.kgc.airquality.airquality.service.impl.QualityService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author shkstart
 * @create 2020-05-20 9:34
 */
@Service
public class QualityServiceImpl implements QualityService {
    @Resource
    QualityMapper qualityMapper;

    @Override
    public PageInfo<Quality> select(Integer pageNum, Integer pageSize, Integer districtId) {
        PageHelper.startPage(pageNum,pageSize);
        List<Quality> qualityList;
        if (districtId!=0){
            QualityExample example=new QualityExample();
            QualityExample.Criteria criteria=example.createCriteria();
            criteria.andDistrictidEqualTo(districtId);
            qualityList=qualityMapper.selectByExample(example);
        }else{
            qualityList=qualityMapper.selectByExample(null);
        }

        PageInfo<Quality>pageInfo=new PageInfo<>(qualityList);
        return pageInfo;
    }
}
